home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 1.iso / ARGONET / PD / PROGRAMMING / DESKLIBC / SOURCES.ZIP / DeskLib / !DLSources / Libraries / Menu / s / FontMenu3
Text File  |  1995-08-26  |  4KB  |  175 lines

  1. ;
  2. ;       Title                  : Font menu creation for RISC OS 3
  3. ;       System                 : Menu library
  4. ;       Version                : 1.0
  5. ;       Copyright              : (c) Ben Summers
  6. ;       Date                   : 21 Oct 94
  7. ;       Author                 : Ben Summers
  8. ;
  9. ;       Function               : Makes a font menu
  10. ;
  11. ;
  12. ;       Modification history.
  13. ;
  14. ;       Version                :
  15. ;       Date                   :
  16. ;       Author                 :
  17. ;       Changes                :
  18. ;
  19. ;
  20. ;============================================================================
  21. ;
  22. ;  Include files.
  23. ;
  24. ;============================================================================
  25. ;
  26.         GET     ^.h.regdefs
  27.         GET     ^.h.swinos
  28.         GET     ^.h.macros
  29. ;
  30. ;============================================================================
  31. ;
  32. ;  Code.
  33. ;
  34. ;============================================================================
  35. ;
  36.         PREAMBLE
  37.  
  38. XFont_ListFonts EQU &40091 + XOS_Bit
  39. XFont_DecodeMenu EQU &400A0 + XOS_Bit
  40.  
  41.         IMPORT  free
  42.         IMPORT  malloc
  43.  
  44.           ; a1 = BOOL sysfont
  45.           ; a2 = char *tick
  46.  
  47.         STARTCODE Menu_FontMenu3
  48.  
  49.         STMFD   sp!,{v1-v6,lr}
  50.         MOV     v5,a1
  51.         MOV     v6,a2
  52.  
  53.         BL      free_data
  54.  
  55.         MOV     a2,#0
  56.         CMP     v5,#0
  57.         MOVEQ   a3,#2_101000:SHL:16
  58.         MOVNE   a3,#2_111000:SHL:16
  59.         MOV     v1,#0
  60.         MOV     v3,v6
  61.         SWI     XFont_ListFonts
  62.         BVS     exit_err
  63.  
  64.         MOV     v4,a4           ; size of font menu buffer
  65.         MOV     v3,v2           ; size of indirected text buffer
  66.  
  67.         MOV     a1,a4
  68.         BL      malloc
  69.         CMP     a1,#0           ; got a buffer?
  70.         BEQ     exit_err
  71.         MOV     v1,a1           ; store it...
  72.         MOV     a1,v3           ; ind data
  73.         BL      malloc
  74.         CMP     a1,#0
  75.         BEQ     no_ind_block
  76.         STR     a1,fontmenu_ind
  77.         STR     v1,fontmenu_def ; store the pointers
  78.  
  79.         MOV     a2,v1           ; font menu definition
  80.         CMP     v5,#0
  81.         MOVEQ   a3,#2_101000:SHL:16
  82.         MOVNE   a3,#2_111000:SHL:16
  83.         MOV     a4,v4           ; size of font menu buffer
  84.         MOV     v1,a1           ; indirected data
  85.         MOV     v2,v3           ; size of ind data
  86.         MOV     v3,v6
  87.         SWI     XFont_ListFonts
  88.         BVS     exit_err_free
  89.  
  90. ; SWI 256+7
  91. exit_err
  92.         LDR     a1,fontmenu_def
  93.         LDMFD   sp!,{v1-v6,pc}^
  94.  
  95. no_ind_block
  96.         MOV     a1,v1
  97.         BL      free            ; doesn't preseve flags
  98.         B       exit_err
  99.  
  100. exit_err_free
  101.         BL      free_data
  102.         B       exit_err
  103.  
  104. free_data
  105.         STMFD   sp!,{lr}
  106.         LDR     a1,fontmenu_def
  107.         CMP     a1,#0
  108.         BLNE    free
  109.         LDR     a1,fontmenu_ind
  110.         CMP     a1,#0
  111.         BLNE    free
  112.         MOV     a1,#0
  113.         STR     a1,fontmenu_def
  114.         STR     a1,fontmenu_ind
  115.         LDMFD   sp!,{pc}^
  116.  
  117.         EXPORT  Menu_FontMenuDecode3
  118.  
  119.           ; a1 = pointer to selection
  120. Menu_FontMenuDecode3
  121.         STMFD   sp!,{v1-v4,lr}
  122.         MOV     v4,a1
  123.         MOV     a3,a1
  124.         MOV     a1,#0
  125.         LDR     a2,fontmenu_def
  126.         MOV     a4,#0           ; find size of answer
  127.         SWI     XFont_DecodeMenu
  128.         BVS     mfmd_err
  129.  
  130.         LDR     a1,answer_size
  131.         CMP     a1,v1
  132.         BGE     mfmd_got_enough
  133.  
  134.         LDR     a1,answer
  135.         BL      free
  136.         MOV     a1,v1
  137.         BL      malloc
  138.         STR     a1,answer
  139.         CMP     a1,#0
  140.         BEQ     mfmd_err
  141.         STR     v1,answer_size
  142.  
  143. mfmd_got_enough
  144.  
  145.         MOV     a1,#0
  146.         LDR     a2,fontmenu_def
  147.         MOV     a3,v4
  148.         LDR     a4,answer
  149.         SWI     XFont_DecodeMenu
  150.         BVS     mfmd_err
  151.  
  152.         LDR     a1,answer
  153.         LDMFD   sp!,{v1-v4,pc}^
  154.  
  155. mfmd_err
  156.         MOV     a1,#0
  157.         LDMFD   sp!,{v1-v4,pc}^
  158.  
  159. menu_fontmenu
  160. fontmenu_def    ; these should really be in an area of their own... but what the hell...
  161.         DCD     0
  162. fontmenu_ind
  163.         DCD     0
  164. answer
  165.         DCD     0
  166. answer_size
  167.         DCD     0
  168.  
  169.         EXPORT  menu_fontmenu
  170.  
  171.           ; two seperate variables instead of one large block to help fit the blocks into
  172.           ; odd places in the heap
  173.  
  174.         END
  175.